---
date: "2021-12-12T00:00:00Z"
external_link: ""
image:
# caption: Photo by rawpixel on Unsplash
# focal_point: Smart
#links:
#- icon: twitter
# icon_pack: fab
# name: Follow
# url: https://twitter.com/georgecushen
#slides: example
summary: A demonstration of scalable faceting using ggplot2 and TrelliscopeJS R pacakges.
tags:
- Data Viz
title: Scalable Faceting with TrelliscopeJS
url_code: ""
url_pdf: ""
url_slides: ""
url_video: ""
---
In this post, I will use TrelliscopeJS (R package) to demonstrate scalable faceting using an example.
Origins
We have multiple origins, including US Gulf, US PNW, Brazil, Ukraine, Argentina from which grain is exported to various destinations.
Destinations
We have multiple destinations, including China, Japan, Indonesia, South Korea, Middle-East, North Africa, The EU, Vietnam.
Change in Shares
Shock model shares are the market shares from each of the origins to all destinations during COVID period while the baseline model shares are the market shares from origins to all destinations using a counterfactual scenario of ocean shipping rates had there been no COVID. The model is an optimized Monte Carlo simulation model using logistics, inland transportation, origin price, port elevation costs computed as a freight-on-board (FOB) port values. To this we add ocean shipping rates for routes from origins to destinations. (For the US and Ukraine origins, we have an additional secondary railcar values as well as cost transporting grain via barge).
Then the change in shares are computed as shown below to identify the losers and winners and if so for which destinations/routes.
Change in shares = Shocked shares - Baseline shares
